<template>
    <header id="outerHeader">
        <section class="headerTop">
            <!-- logo -->
            <img src="https://course.myhope365.com/img/logo-header.08ec1297.png" alt="">

            <!-- 搜索 -->
            <div class="searchText">
                <input type="search" name="" id="" placeholder="搜索课程" v-model='value'>
                <a href="search.html?keyword=&subjectId=&type=&courseType=">
                    <button>
                        <img src="../images/搜索.png" alt="" style="margin-right: 4px;">
                    <span>搜索</span></button></a>

            </div>
            <div class="loginBox">
                <img src="../images/购物车.png" alt="" class="car">
                <span data-toggle="modal" data-target="#myModal">登录/注册</span>
                <div>
                    <img src="../images/个人.png" alt="" class="self">
                </div>
            </div>

<!-----------------------模态框位置---------------------->
        </section>
        <ul id="nav">
            <li style="position: relative"><a href="#">
                首页
            </a>
                <div class="searched"></div>
            </li>
            <li id="top" @mouseenter='showEnter' @mouseleave="showLeave">
                <a href="#" id="courseImg">
                    课程分类
                    <img src="../images/下箭头.png" alt="">
                </a>
            </li>
            <li><a href="#">
                专属课程
            </a></li>
            <ul id="courseId" v-show="flag" @mouseenter='showEnter' @mouseleave="showLeave">
                <li v-for='(item,index) in list' :key="index">
                    <a :href="getHref(item.subjectId)">
                        {{item.subjectTitle}}
                    </a>
                </li>
            </ul>
        </ul>
        <div style="clear:both"></div>
    </header>
</template>

<script>
    import '../myHeader.less'
    export default {
        name: "MyHeader",
        data() {
            return {
                list: [],
                value: '',
                flag: false
            }
        },
        methods: {
            getHref: function (val) {
                return "search.html?subjectId=" + val + "&keyword=" + this.value + "&courseType=&type="
            },
            showEnter() {
                this.flag = true;
            },
            showLeave() {
                this.flag = false;
            }
        },
        props: {
        },
        created() {
            this.$axios
                .post('http://wkt.myhope365.com//weChat/applet/subject/list', { enable: 1 })
                .then(res => {
                    // console.log(res.data.rows);
                    this.list = res.data.rows

                })
        }
    }
</script>

<style scoped>


</style>